<?php 

namespace Acme\UserBundle\Form;
 
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilder;

class UserCreateType extends AbstractType
{
    public function buildForm(FormBuilder $builder, array $options)
    {
    	if (in_array('ROLE_SUPER_ADMIN', $options['role'])) {
    		$builder->add('userCategory', 'userCategory', array('label' => '用户类型', 'empty_value' => '请选择', 'property_path' => false));
    		$builder->add('university', 'universitySelector', array('label' => '所在大学', 'property_path' => false));
    	} else {
    		$builder->add('userCategory', 'universityUserCategory', array('label' => '用户类型', 'empty_value' => '请选择', 'property_path' => false));
    	}
    	
    	$builder->add('username', 'text', array('label' => '用户名'));
    	$builder->add('email', 'email', array('label' => '邮箱'));
    }
    
    // the name of the class that holds the underlying data(for use of function createForm)
    public function getDefaultOptions(array $options)
    {
    	return array(
   				'data_class' => 'Acme\UserBundle\Entity\CmUser',
   				'required' => false,
    			'role' => $options['role'],
    	);
    }
    
    // note that the getName() method should return a unique identifier for this form "type"
    public function getName()
    {
    	return 'user_create';
    }
}